package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.net.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	
	public class FramePet extends JFrame
	{
		//members define
		private var panelBLeft:JPanel;
		private var panel72:JPanel;
		private var panelPet_0:PanePetItem;
		private var panelPet_1:PanePetItem;
		private var panelPet_2:PanePetItem;
		private var panelPet_3:PanePetItem;
		private var panelBRight:JPanel;
		private var labelName:JLabel;
		private var btn_change_name:JButton;
		private var labelLove:JLabel;
		private var labelEXP:JLabel;
		private var labelHP:JLabel;
		private var labelAP:JLabel;
		private var labelDP:JLabel;
		private var labelSP:JLabel;
		private var labelResistHL:JLabel;
		private var labelResistBD:JLabel;
		private var labelResistHS:JLabel;
		private var btnHPAdd:JButton;
		private var btnAPAdd:JButton;
		private var btnDPAdd:JButton;
		private var btnSPAdd:JButton;
		private var panelButtons:JPanel;
		private var btn_pet_free:JButton;
		private var btn_pet_battle:JButton;
		private var btn_pet_battle_setting:JButton;
		private var panel103:JPanel;
		private var btn_pet_white:JToggleButton;
		private var btn_pet_green:JToggleButton;
		private var btn_pet_blue:JToggleButton;
		private var btn_pet_purple:JToggleButton;
		private var btn_pet_golden:JToggleButton;
		private var panelSkills:JPanel;
		private var panel_skill_0:PanelSkill;
		private var btn_lock_0:JButton;
		private var panel_skill_1:PanelSkill;
		private var btn_lock_1:JButton;
		private var panel_skill_2:PanelSkill;
		private var btn_lock_2:JButton;
		private var panel_skill_3:PanelSkill;
		private var btn_lock_3:JButton;
		private var panel_skill_4:PanelSkill;
		private var btn_lock_4:JButton;
		private var panel_skill_5:PanelSkill;
		private var btn_lock_5:JButton;
		//private var panel108:JPanel;
		private var panelLeftButtons:JPanel;
		private var btn_page_prev:JButton;
		private var labelPage:JLabel;
		private var btn_page_next:JButton;
		
		//---------------------------------------
		private var btn_close:JButton;
		private var background:String;
		public static var _mcPetHead:MovieClip = null;
		private var _skills:Array = new Array();
		//private var _tooltips:Array = new Array;
		public function FramePet()
		{
			
			
			setResizable(false);
			setBackgroundDecorator(null);
			setBorder(new EmptyBorder());
			
			btn_close = new JButton();
			btn_close.setSize(new IntDimension(27, 27));
			btn_close.setPreferredSize(new IntDimension(27, 27));
			getTitleBar().setCloseButton(btn_close);
			getTitleBar().setMinimizeHeight(32);
			
			//component creation
			setSize(new IntDimension(370, 399));
			setPreferredSize(new IntDimension(370, 399));
			var layout0:EmptyLayout = new EmptyLayout();
			getContentPane().setLayout(layout0);
			
			panelBLeft = new JPanel();
			panelBLeft.setLocation(new IntPoint(0, 0));
			panelBLeft.setSize(new IntDimension(173, 348));
			panelBLeft.setPreferredSize(new IntDimension(173, 348));
			var layout1:EmptyLayout = new EmptyLayout();
			panelBLeft.setLayout(layout1);
			
			panel72 = new JPanel();
			panel72.setLocation(new IntPoint(7, 0));
			panel72.setSize(new IntDimension(163, 348));
			panel72.setPreferredSize(new IntDimension(163, 348));
			var layout2:FlowLayout = new FlowLayout();
			layout2.setAlignment(AsWingConstants.CENTER);
			layout2.setHgap(5);
			layout2.setVgap(7);
			layout2.setMargin(false);
			panel72.setLayout(layout2);
			
			panelPet_0 = new PanePetItem();
			panelPet_0.setLocation(new IntPoint(5, 0));
			panelPet_0.setSize(new IntDimension(163, 80));
			panelPet_0.setPreferredSize(new IntDimension(163, 80));
			var layout3:EmptyLayout = new EmptyLayout();
			panelPet_0.setLayout(layout3);
			
			panelPet_1 = new PanePetItem();
			panelPet_1.setLocation(new IntPoint(5, 87));
			panelPet_1.setSize(new IntDimension(163, 80));
			panelPet_1.setPreferredSize(new IntDimension(163, 80));
			var layout4:EmptyLayout = new EmptyLayout();
			panelPet_1.setLayout(layout4);
			
			panelPet_2 = new PanePetItem();
			panelPet_2.setLocation(new IntPoint(5, 174));
			panelPet_2.setSize(new IntDimension(163, 80));
			panelPet_2.setPreferredSize(new IntDimension(163, 80));
			var layout5:EmptyLayout = new EmptyLayout();
			panelPet_2.setLayout(layout5);
			
			panelPet_3 = new PanePetItem();
			panelPet_3.setLocation(new IntPoint(5, 261));
			panelPet_3.setSize(new IntDimension(163, 80));
			panelPet_3.setPreferredSize(new IntDimension(163, 80));
			
			panelBRight = new JPanel();
			panelBRight.setLocation(new IntPoint(173, 0));
			panelBRight.setSize(new IntDimension(197, 399));
			panelBRight.setPreferredSize(new IntDimension(197, 399));
			var layout6:EmptyLayout = new EmptyLayout();
			panelBRight.setLayout(layout6);
			
			labelName = new JLabel();
			labelName.setLocation(new IntPoint(41, 10));
			labelName.setSize(new IntDimension(96, 19));
			labelName.setPreferredSize(new IntDimension(96, 19));
			labelName.setText("label");
			
			btn_change_name = new JButton();
			btn_change_name.setLocation(new IntPoint(146, 12));
			btn_change_name.setSize(new IntDimension(25, 18));
			btn_change_name.setPreferredSize(new IntDimension(25, 18));
			btn_change_name.setText("label");
			
			labelLove = new JLabel();
			labelLove.setLocation(new IntPoint(34, 103));
			labelLove.setSize(new IntDimension(66, 16));
			labelLove.setPreferredSize(new IntDimension(66, 16));
			labelLove.setText("label");
			
			labelEXP = new JLabel();
			labelEXP.setLocation(new IntPoint(34, 127));
			labelEXP.setSize(new IntDimension(66, 16));
			labelEXP.setPreferredSize(new IntDimension(66, 16));
			labelEXP.setText("label");
			
			labelHP = new JLabel();
			labelHP.setLocation(new IntPoint(34, 162));
			labelHP.setSize(new IntDimension(66, 16));
			labelHP.setPreferredSize(new IntDimension(66, 16));
			labelHP.setText("label");
			
			labelAP = new JLabel();
			labelAP.setLocation(new IntPoint(34, 186));
			labelAP.setSize(new IntDimension(66, 16));
			labelAP.setPreferredSize(new IntDimension(66, 16));
			labelAP.setText("label");
			
			labelDP = new JLabel();
			labelDP.setLocation(new IntPoint(34, 210));
			labelDP.setSize(new IntDimension(66, 16));
			labelDP.setPreferredSize(new IntDimension(66, 16));
			labelDP.setText("label");
			
			labelSP = new JLabel();
			labelSP.setLocation(new IntPoint(34, 234));
			labelSP.setSize(new IntDimension(66, 16));
			labelSP.setPreferredSize(new IntDimension(66, 16));
			labelSP.setText("label");
			
			labelResistHL = new JLabel();
			labelResistHL.setLocation(new IntPoint(49, 271));
			labelResistHL.setSize(new IntDimension(69, 14));
			labelResistHL.setPreferredSize(new IntDimension(69, 14));
			labelResistHL.setText("label");
			
			labelResistBD = new JLabel();
			labelResistBD.setLocation(new IntPoint(49, 293));
			labelResistBD.setSize(new IntDimension(69, 14));
			labelResistBD.setPreferredSize(new IntDimension(69, 14));
			labelResistBD.setText("label");
			
			labelResistHS = new JLabel();
			labelResistHS.setLocation(new IntPoint(49, 315));
			labelResistHS.setSize(new IntDimension(69, 14));
			labelResistHS.setPreferredSize(new IntDimension(69, 14));
			labelResistHS.setText("label");
			
			btnHPAdd = new JButton();
			btnHPAdd.setLocation(new IntPoint(102, 162));
			btnHPAdd.setSize(new IntDimension(20, 20));
			btnHPAdd.setPreferredSize(new IntDimension(20, 20));
			btnHPAdd.setText("label");
			
			btnAPAdd = new JButton();
			btnAPAdd.setLocation(new IntPoint(102, 186));
			btnAPAdd.setSize(new IntDimension(20, 20));
			btnAPAdd.setPreferredSize(new IntDimension(20, 20));
			btnAPAdd.setText("label");
			
			btnDPAdd = new JButton();
			btnDPAdd.setLocation(new IntPoint(102, 210));
			btnDPAdd.setSize(new IntDimension(20, 20));
			btnDPAdd.setPreferredSize(new IntDimension(20, 20));
			btnDPAdd.setText("label");
			
			btnSPAdd = new JButton();
			btnSPAdd.setLocation(new IntPoint(102, 234));
			btnSPAdd.setSize(new IntDimension(20, 20));
			btnSPAdd.setPreferredSize(new IntDimension(20, 20));
			btnSPAdd.setText("label");
			
			panelButtons = new JPanel();
			panelButtons.setLocation(new IntPoint(0, 350));
			panelButtons.setSize(new IntDimension(197, 24));
			panelButtons.setPreferredSize(new IntDimension(197, 24));
			var layout7:FlowWrapLayout = new FlowWrapLayout();
			layout7.setPreferWidth(200);
			layout7.setAlignment(AsWingConstants.CENTER);
			layout7.setHgap(5);
			layout7.setVgap(0);
			layout7.setMargin(false);
			panelButtons.setLayout(layout7);
			
			btn_pet_free = new JButton();
			btn_pet_free.setLocation(new IntPoint(36, 0));
			btn_pet_free.setSize(new IntDimension(49, 24));
			btn_pet_free.setPreferredSize(new IntDimension(49, 23));
			btn_pet_free.setText("label");
			
			btn_pet_battle = new JButton();
			btn_pet_battle.setLocation(new IntPoint(108, 0));
			btn_pet_battle.setSize(new IntDimension(49, 24));
			btn_pet_battle.setPreferredSize(new IntDimension(49, 23));
			btn_pet_battle.setText("label");
			
			btn_pet_battle_setting = new JButton();
			btn_pet_battle_setting.setLocation(new IntPoint(62, 23));
			btn_pet_battle_setting.setSize(new IntDimension(72, 23));
			btn_pet_battle_setting.setPreferredSize(new IntDimension(72, 23));
			btn_pet_battle_setting.setText("label");
			
			panel103 = new JPanel();
			panel103.setLocation(new IntPoint(16, 39));
			panel103.setSize(new IntDimension(156, 33));
			panel103.setPreferredSize(new IntDimension(156, 33));
			var layout8:FlowLayout = new FlowLayout();
			layout8.setAlignment(AsWingConstants.LEFT);
			layout8.setHgap(0);
			layout8.setVgap(3);
			layout8.setMargin(true);
			panel103.setLayout(layout8);
			
			btn_pet_white = new JToggleButton();
			btn_pet_white.setLocation(new IntPoint(5, 5));
			btn_pet_white.setSize(new IntDimension(31, 30));
			btn_pet_white.setPreferredSize(new IntDimension(31, 30));
			btn_pet_white.setText("label");
			
			btn_pet_green = new JToggleButton();
			btn_pet_green.setLocation(new IntPoint(41, 5));
			btn_pet_green.setSize(new IntDimension(31, 30));
			btn_pet_green.setPreferredSize(new IntDimension(31, 30));
			btn_pet_green.setText("label");
			
			btn_pet_blue = new JToggleButton();
			btn_pet_blue.setLocation(new IntPoint(77, 5));
			btn_pet_blue.setSize(new IntDimension(31, 30));
			btn_pet_blue.setPreferredSize(new IntDimension(31, 30));
			btn_pet_blue.setText("label");
			
			btn_pet_purple = new JToggleButton();
			btn_pet_purple.setLocation(new IntPoint(113, 5));
			btn_pet_purple.setSize(new IntDimension(31, 30));
			btn_pet_purple.setPreferredSize(new IntDimension(31, 30));
			btn_pet_purple.setText("label");
			
			btn_pet_golden = new JToggleButton();
			btn_pet_golden.setLocation(new IntPoint(149, 5));
			btn_pet_golden.setSize(new IntDimension(31, 30));
			btn_pet_golden.setPreferredSize(new IntDimension(31, 30));
			btn_pet_golden.setText("label");
			
			panelSkills = new JPanel();
			panelSkills.setLocation(new IntPoint(122, 93));
			panelSkills.setSize(new IntDimension(63, 245));
			panelSkills.setPreferredSize(new IntDimension(63, 245));
			var layout9:EmptyLayout = new EmptyLayout();
			panelSkills.setLayout(layout9);
			
			panel_skill_0 = new PanelSkill();
			panel_skill_0.setLocation(new IntPoint(0, 0));
			panel_skill_0.setSize(new IntDimension(40, 40));
			panel_skill_0.setPreferredSize(new IntDimension(40, 40));
			
			btn_lock_0 = new JButton();
			btn_lock_0.setLocation(new IntPoint(41, 9));
			btn_lock_0.setSize(new IntDimension(21, 22));
			btn_lock_0.setPreferredSize(new IntDimension(21, 22));
			btn_lock_0.setText("label");
			
			panel_skill_1 = new PanelSkill();
			panel_skill_1.setLocation(new IntPoint(0, 41));
			panel_skill_1.setSize(new IntDimension(40, 40));
			panel_skill_1.setPreferredSize(new IntDimension(40, 40));
			
			btn_lock_1 = new JButton();
			btn_lock_1.setLocation(new IntPoint(41, 50));
			btn_lock_1.setSize(new IntDimension(21, 22));
			btn_lock_1.setPreferredSize(new IntDimension(21, 22));
			btn_lock_1.setText("label");
			
			panel_skill_2 = new PanelSkill();
			panel_skill_2.setLocation(new IntPoint(0, 82));
			panel_skill_2.setSize(new IntDimension(40, 40));
			panel_skill_2.setPreferredSize(new IntDimension(40, 40));
			
			btn_lock_2 = new JButton();
			btn_lock_2.setLocation(new IntPoint(41, 91));
			btn_lock_2.setSize(new IntDimension(21, 22));
			btn_lock_2.setPreferredSize(new IntDimension(21, 22));
			btn_lock_2.setText("label");
			
			panel_skill_3 = new PanelSkill();
			panel_skill_3.setLocation(new IntPoint(0, 123));
			panel_skill_3.setSize(new IntDimension(40, 40));
			panel_skill_3.setPreferredSize(new IntDimension(40, 40));
			
			btn_lock_3 = new JButton();
			btn_lock_3.setLocation(new IntPoint(41, 132));
			btn_lock_3.setSize(new IntDimension(21, 22));
			btn_lock_3.setPreferredSize(new IntDimension(21, 22));
			btn_lock_3.setText("label");
			
			panel_skill_4 = new PanelSkill();
			panel_skill_4.setLocation(new IntPoint(0, 164));
			panel_skill_4.setSize(new IntDimension(40, 40));
			panel_skill_4.setPreferredSize(new IntDimension(40, 40));
			
			btn_lock_4 = new JButton();
			btn_lock_4.setLocation(new IntPoint(41, 173));
			btn_lock_4.setSize(new IntDimension(21, 22));
			btn_lock_4.setPreferredSize(new IntDimension(21, 22));
			btn_lock_4.setText("label");
			
			panel_skill_5 = new PanelSkill();
			panel_skill_5.setLocation(new IntPoint(0, 205));
			panel_skill_5.setSize(new IntDimension(40, 40));
			panel_skill_5.setPreferredSize(new IntDimension(40, 40));
			
			btn_lock_5 = new JButton();
			btn_lock_5.setLocation(new IntPoint(41, 214));
			btn_lock_5.setSize(new IntDimension(21, 22));
			btn_lock_5.setPreferredSize(new IntDimension(21, 22));
			btn_lock_5.setText("label");
			
			//panel108 = new JPanel();
			//panel108.setLocation(new IntPoint(16, 39));
			//panel108.setSize(new IntDimension(156, 33));
			//panel108.setPreferredSize(new IntDimension(156, 33));
			
			panelLeftButtons = new JPanel();
			panelLeftButtons.setLocation(new IntPoint(0, 353));
			panelLeftButtons.setSize(new IntDimension(173, 24));
			panelLeftButtons.setPreferredSize(new IntDimension(173, 24));
			var layout10:EmptyLayout = new EmptyLayout();
			panelLeftButtons.setLayout(layout10);
			
			btn_page_prev = new JButton();
			btn_page_prev.setLocation(new IntPoint(36, 0));
			btn_page_prev.setSize(new IntDimension(29, 24));
			btn_page_prev.setPreferredSize(new IntDimension(29, 24));
			btn_page_prev.setText("label");
			
			labelPage = new JLabel();
			labelPage.setLocation(new IntPoint(75, 3));
			labelPage.setSize(new IntDimension(37, 17));
			labelPage.setPreferredSize(new IntDimension(37, 17));
			labelPage.setText("1/3");
			
			btn_page_next = new JButton();
			btn_page_next.setLocation(new IntPoint(122, 0));
			btn_page_next.setSize(new IntDimension(29, 24));
			btn_page_next.setPreferredSize(new IntDimension(29, 24));
			btn_page_next.setText("label");
			
			//component layoution
			getContentPane().append(panelBLeft);
			getContentPane().append(panelBRight);
			getContentPane().append(panelLeftButtons);
			
			panelBLeft.append(panel72);
			
			panel72.append(panelPet_0);
			panel72.append(panelPet_1);
			panel72.append(panelPet_2);
			panel72.append(panelPet_3);
			
			panelBRight.append(labelName);
			panelBRight.append(btn_change_name);
			panelBRight.append(labelLove);
			panelBRight.append(labelEXP);
			panelBRight.append(labelHP);
			panelBRight.append(labelAP);
			panelBRight.append(labelDP);
			panelBRight.append(labelSP);
			panelBRight.append(labelResistHL);
			panelBRight.append(labelResistBD);
			panelBRight.append(labelResistHS);
			panelBRight.append(btnHPAdd);
			panelBRight.append(btnAPAdd);
			panelBRight.append(btnDPAdd);
			panelBRight.append(btnSPAdd);
			panelBRight.append(panelButtons);
			panelBRight.append(panel103);
			panelBRight.append(panelSkills);
			//panelBRight.append(panel108);
			
			panelButtons.append(btn_pet_free);
			panelButtons.append(btn_pet_battle_setting);
			panelButtons.append(btn_pet_battle);
			
			panel103.append(btn_pet_white);
			panel103.append(btn_pet_green);
			panel103.append(btn_pet_blue);
			panel103.append(btn_pet_purple);
			panel103.append(btn_pet_golden);
			
			panelSkills.append(panel_skill_0);
			panelSkills.append(btn_lock_0);
			panelSkills.append(panel_skill_1);
			panelSkills.append(btn_lock_1);
			panelSkills.append(panel_skill_2);
			panelSkills.append(btn_lock_2);
			panelSkills.append(panel_skill_3);
			panelSkills.append(btn_lock_3);
			panelSkills.append(panel_skill_4);
			panelSkills.append(btn_lock_4);
			panelSkills.append(panel_skill_5);
			panelSkills.append(btn_lock_5);
			
			panelLeftButtons.append(btn_page_prev);
			panelLeftButtons.append(labelPage);
			panelLeftButtons.append(btn_page_next);
			
			//-------------------------------------------
			
			setImages();
			
			panelBRight.setClipMasked(false);
			panelLeftButtons.setClipMasked(false);
			
		}
		
		public function onUpdateData():void
		{
			update();
		}
		private var _petItems:Array = new Array();
		public function setImages():void
		{
			var img_char_background:DisplayObject = Client.getUIElement("img_pet_pet_bg") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_char_background));
			setSizeWH(img_char_background.width,img_char_background.height);
			setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
			
			btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
			
			btn_change_name.wrapSimpleButton(Client.getUIElement("btn_pet_change_name") as SimpleButton);
			//btn_pet_free.wrapSimpleButton(Client.getUIElement("btn_pet_free") as SimpleButton);
			//btn_pet_battle.wrapSimpleButton(Client.getUIElement("btn_pet_battle") as SimpleButton);
			btn_pet_free.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
			btn_pet_battle.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
			btn_pet_battle_setting.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
			btn_page_prev.wrapSimpleButton(Client.getUIElement("btn_prev") as SimpleButton);
			btn_page_next.wrapSimpleButton(Client.getUIElement("btn_next") as SimpleButton);
			btn_change_name.setText("");
			btn_pet_free.setText("释放");
			btn_pet_battle.setText("参战");
			btn_pet_battle_setting.setText("战斗设置");
			btn_page_prev.setText("");
			btn_page_next.setText("");
			
			btnHPAdd.addActionListener(onBtnHPAdd);
			btnAPAdd.addActionListener(onBtnAPAdd);
			btnDPAdd.addActionListener(onBtnDPAdd);
			btnSPAdd.addActionListener(onBtnSPAdd);
			btnHPAdd.setToolTipText("强化生命");
			btnAPAdd.setToolTipText("强化攻击");
			btnDPAdd.setToolTipText("强化防御");
			btnHPAdd.setToolTipText("强化速度");
			btn_page_prev.addActionListener(onBtnPrev);
			btn_page_next.addActionListener(onBtnNext);
			btn_change_name.addActionListener(onBtnChangeName);

			btnHPAdd.setText("");
			btnAPAdd.setText("");
			btnDPAdd.setText("");
			btnSPAdd.setText("");
			
			btnHPAdd.wrapSimpleButton(Client.getUIElement("btn_char_add") as SimpleButton);
			btnAPAdd.wrapSimpleButton(Client.getUIElement("btn_char_add") as SimpleButton);
			btnDPAdd.wrapSimpleButton(Client.getUIElement("btn_char_add") as SimpleButton);
			btnSPAdd.wrapSimpleButton(Client.getUIElement("btn_char_add") as SimpleButton);
			
			btn_pet_white.setText("");
			btn_pet_white.wrapSimpleButton(Client.getUIElement("btn_pet_white") as SimpleButton);
			btn_pet_green.setText("");
			btn_pet_green.wrapSimpleButton(Client.getUIElement("btn_pet_green") as SimpleButton);
			btn_pet_blue.setText("");
			btn_pet_blue.wrapSimpleButton(Client.getUIElement("btn_pet_blue") as SimpleButton);
			btn_pet_purple.setText("");
			btn_pet_purple.wrapSimpleButton(Client.getUIElement("btn_pet_purple") as SimpleButton);
			btn_pet_golden.setText("");
			btn_pet_golden.wrapSimpleButton(Client.getUIElement("btn_pet_golden") as SimpleButton);
			
			btn_pet_white.addActionListener(onBtnGrowth);
			btn_pet_green.addActionListener(onBtnGrowth);
			btn_pet_blue.addActionListener(onBtnGrowth);
			btn_pet_purple.addActionListener(onBtnGrowth);
			btn_pet_golden.addActionListener(onBtnGrowth);
			
			var group:ButtonGroup = new ButtonGroup();
			group.appendAll(btn_pet_white,btn_pet_green,btn_pet_blue,btn_pet_purple,btn_pet_golden);
			group.setAllowUncheck(false);
			
			btn_lock_0.setText("");
			btn_lock_0.wrapSimpleButton(Client.getUIElement("btn_pet_lock") as SimpleButton);
			btn_lock_1.setText("");
			btn_lock_1.wrapSimpleButton(Client.getUIElement("btn_pet_lock") as SimpleButton);
			btn_lock_2.setText("");
			btn_lock_2.wrapSimpleButton(Client.getUIElement("btn_pet_lock") as SimpleButton);
			btn_lock_3.setText("");
			btn_lock_3.wrapSimpleButton(Client.getUIElement("btn_pet_lock") as SimpleButton);
			btn_lock_4.setText("");
			btn_lock_4.wrapSimpleButton(Client.getUIElement("btn_pet_lock") as SimpleButton);
			btn_lock_5.setText("");
			btn_lock_5.wrapSimpleButton(Client.getUIElement("btn_pet_lock") as SimpleButton);
			
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 10);
			
			labelName.setFont(font);
			labelName.setForeground(ASColor.WHITE);
			labelName.setTextFilters(new Array(filter));
			
			labelLove.setFont(font);
			labelLove.setForeground(ASColor.WHITE);
			labelLove.setTextFilters(new Array(filter));
			labelEXP.setFont(font);
			labelEXP.setForeground(ASColor.WHITE);
			labelEXP.setTextFilters(new Array(filter));
			labelHP.setFont(font);
			labelHP.setForeground(ASColor.WHITE);
			labelHP.setTextFilters(new Array(filter));
			labelAP.setFont(font);
			labelAP.setForeground(ASColor.WHITE);
			labelAP.setTextFilters(new Array(filter));
			labelDP.setFont(font);
			labelDP.setForeground(ASColor.WHITE);
			labelDP.setTextFilters(new Array(filter));
			labelResistHL.setFont(font);
			labelResistHL.setForeground(ASColor.WHITE);
			labelResistHL.setTextFilters(new Array(filter));
			labelResistBD.setFont(font);
			labelResistBD.setForeground(ASColor.WHITE);
			labelResistBD.setTextFilters(new Array(filter));
			labelSP.setFont(font);
			labelSP.setForeground(ASColor.WHITE);
			labelSP.setTextFilters(new Array(filter));
			labelResistHS.setFont(font);
			labelResistHS.setForeground(ASColor.WHITE);
			labelResistHS.setTextFilters(new Array(filter));
			
			labelPage.setFont(font);
			labelPage.setForeground(ASColor.WHITE);
			labelPage.setTextFilters(new Array(filter));
			
			font = new ASFont("宋体", 13, false, false, false, false);
			
			btn_pet_free.setForeground(ASColor.WHITE);
			btn_pet_free.setBackground(ASColor.GRAY);
			btn_pet_free.setTextFilters(new Array(filter));
			btn_pet_free.setFont(font);
			
			btn_pet_battle.setForeground(ASColor.WHITE);
			btn_pet_battle.setBackground(ASColor.GRAY);
			btn_pet_battle.setTextFilters(new Array(filter));
			btn_pet_battle.setFont(font);
			
			btn_pet_battle_setting.setForeground(ASColor.WHITE);
			btn_pet_battle_setting.setTextFilters(new Array(filter));
			btn_pet_battle_setting.setFont(font);
			
			_skills.push(panel_skill_0);
			_skills.push(panel_skill_1);
			_skills.push(panel_skill_2);
			_skills.push(panel_skill_3);
			_skills.push(panel_skill_4);
			_skills.push(panel_skill_5);
			var nIndex:uint = 0;
			for each (var item:PanelSkill in _skills)
			{
				item.index = nIndex++;
			}
			
			btn_pet_battle.addActionListener(onJoinBattle);
			btn_pet_free.addActionListener(onBtnFree);
			btn_pet_battle_setting.addActionListener(onBtnBattleSetting);
			
			_petItems.push(panelPet_0);
			_petItems.push(panelPet_1);
			_petItems.push(panelPet_2);
			_petItems.push(panelPet_3);
			panelSkills.setClipMasked(false);
			
		}
		
		private var _currentPageIndex:int = 0;
		private var _currentPageIndexAll:int = 0;
		private var _itemsPerPage:int = 4;
		public function updatePage():void
		{
			if(_currentPageIndex >= Math.floor((CharInfo.m_arPets.length+_itemsPerPage-1)/_itemsPerPage))
				_currentPageIndex = 0;
			for each(var obj:Object in _petItems)
			{
				obj.item = null;
			}
			var nIndex:int = 0;
			var nCount:int = 0;
			for each(var item:Object in CharInfo.m_arPets)
			{
				nCount++;
				if(nCount <= _currentPageIndex*_itemsPerPage)
					continue;
				_petItems[nIndex++].item = item;
				if(nIndex >= _itemsPerPage)
					break;
			}
			var nCount1:int = CharInfo.m_arPets.length;
			_currentPageIndexAll = Math.floor((nCount1+_itemsPerPage-1)/_itemsPerPage);
			labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
			btn_page_prev.setEnabled(_currentPageIndex > 0 &&  _currentPageIndexAll > 1);
			btn_page_next.setEnabled(_currentPageIndex < _currentPageIndexAll-1 &&  _currentPageIndexAll > 1);
			
		}
		
		private function onBtnPrev(event:Event):void
		{
			_currentPageIndex--;
			if(_currentPageIndex < 0)
				_currentPageIndex = 0;
			else
				updatePage();
			labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
		}
		private function onBtnNext(event:Event):void
		{
			_currentPageIndex++;
			if(_currentPageIndex > _currentPageIndexAll-1)
				_currentPageIndex = _currentPageIndexAll-1;
			else
				updatePage();
			labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
		}
		
		private function onBtnOK(e:Event):void
		{
			if(PanelMain.getInstance().isInBattle)
			{
				PanelMain.showInfo("在战斗中不能为宠物分配点数!");
				return;
			}
			
			if(selectedIndex == -1 || selectedIndex >= CharInfo.m_arPets.length)
				return;
			//Client.getInstance().sendPacketLogic(105,[selectedIndex,int(CharInfo.m_arPets[selectedIndex].id),_tmpHPAdd,_tmpEPAdd,_tmpAPAdd,_tmpSPAdd]);

			update();
		}

		private function onBtnHPAdd(e:Event):void
		{
			FrameStrengthen.show(labelName.getText(),5/*int(labelLevel.getText())*/,0,1,selectedIndex);
		}

		private function onBtnAPAdd(e:Event):void
		{
			FrameStrengthen.show(labelName.getText(),5/*int(labelLevel.getText())*/,1,1,selectedIndex);
		}

		private function onBtnDPAdd(e:Event):void
		{
			FrameStrengthen.show(labelName.getText(),5/*int(labelLevel.getText())*/,2,1,selectedIndex);
		}
		
		private function onBtnSPAdd(e:Event):void
		{
			FrameStrengthen.show(labelName.getText(),5/*int(labelLevel.getText())*/,3,1,selectedIndex);
		}

		
		/*private function onRollOver(event:MouseEvent):void
		{
			var target:JPanel = event.target as JPanel;
			if(!(target.getBorder() is EmptyBorder))
				return;
			target.setBorder(new LineBorder(null,ASColor.GREEN));
		}
		
		private function onRollOut(event:MouseEvent):void
		{
			var target:JPanel = event.target as JPanel;
			target.setBorder(new EmptyBorder());
		}
		
		//是否接受这个被拖入的组件
		private function onDropAppraiser(initiator:JPanel):Boolean
		{
			return true;
		}
		//被接受的组件被拖入时，改变Panel背景色
		private function onDragEnter(e:DragAndDropEvent):void
		{
			var initiator:PanelSkill = e.getDragInitiator() as PanelSkill;
			if(onDropAppraiser(initiator))
			{
				if(e.target is PanelSkill)
				{
					var target:PanelSkill = e.target as PanelSkill;
					target.setBorder(new LineBorder(null,ASColor.GREEN));
				}
			}
		}
		
		//组件被拖出时，恢复原来的背景色
		private function onDragExit(e:DragAndDropEvent):void
		{
			if(e.target is PanelSkill)
			{
				var target:JPanel = e.target as JPanel;
				target.setBorder(new EmptyBorder());
			}
		}
		//组件被释放时，如果是被接受的，那么把它加入此面板
		private function onDragDrop(event:DragAndDropEvent):void
		{
			var initiator:PanelSkill = event.getDragInitiator() as PanelSkill;
			if(event.target is PanelSkill)
			{
				var target:PanelSkill = event.target as PanelSkill;
				target.setBorder(new EmptyBorder());
				if(onDropAppraiser(initiator))
				{
				}
			}
		}
		
		//private var _currentIndex:uint = 0;
		private function onDragRecognized( e:DragAndDropEvent):void
		{
			var btn:PanelSkill = e.target as PanelSkill;
			if(btn.icon_id <= 0)
				return;
			DragManager.startDrag(btn,new SourceData("item", btn.getToolTipText()),new DraggingImageSkill(btn)); 
		}*/
		private function onSkillClickCount(event:ClickCountEvent):void
		{   
			
			if(event.getCount() >= 2)
			{   
				
				//处理  
				//trace("onDoubleClickItem"); 
				
			}   
			
		} 
		
		private function onBtnChangeName(e:Event):void
		{
			FrameInfo.showInputDialog("","请输入新名字: ",handleOptionChangeName,"",null,true,null);
		}

		private function handleOptionChangeName(inputText:String):void
		{
			if(inputText !=	null)
			{
				if(inputText.length <= 0)
				{
					FrameInfo.showMessageDialog("","请输入新名字!",null,null,true,null);
					return;
				}

				Client.getInstance().sendPacketLogic(101,[selectedIndex,inputText]);
			}
			
		}
		
		public var selectedIndex:int = -1;
		public function update():void
		{
			if(selectedIndex >= CharInfo.m_arPets.length)
			{
				selectedIndex = CharInfo.m_arPets.length > 0 ? 0 : -1;
			}
			updatePet(CharInfo.m_nPetJoinBattleIndex != -1 ? CharInfo.m_nPetJoinBattleIndex :selectedIndex);
			updatePage();
		}
		private var selectedButton:JToggleButton = null;
		public function updatePet(index:int):void
		{
			selectedIndex = index;
			var isNull:Boolean = (index == -1) || index >= CharInfo.m_arPets.length;
			
			labelName.setText(isNull ? "" : CharInfo.m_arPets[index].name);
			//labelLove.setText(isNull ? "0" : CharInfo.m_arPets[index].love.toString());
			labelEXP.setText(isNull ? "0" : CharInfo.m_arPets[index].exp.toString() + "/" + CharInfo.m_arPets[index].exp_max.toString());
			
			labelHP.setText(isNull ? "0" : CharInfo.m_arPets[index].hp_max.toString());
			labelAP.setText(isNull ? "0" : CharInfo.m_arPets[index].ap.toString());
			labelDP.setText(isNull ? "0" : CharInfo.m_arPets[index].dp.toString());
			labelSP.setText(isNull ? "0" : CharInfo.m_arPets[index].sp.toString());
			
			labelHP.setToolTipText("生命:"+ (isNull ? "0" : CharInfo.m_arPets[index].hp_max));
			
			labelAP.setToolTipText("攻击:"+ (isNull ? "0" : CharInfo.m_arPets[index].ap.toString()));
			
			labelDP.setToolTipText("防御:"+ (isNull ? "0" : CharInfo.m_arPets[index].dp.toString()));

			labelSP.setToolTipText("速度:"+ (isNull ? "0" : CharInfo.m_arPets[index].sp.toString()));
			
			
			labelResistHL.setText(isNull ? "0" : CharInfo.m_arPets[index].resistHL.toString());
			labelResistBD.setText(isNull ? "0" : CharInfo.m_arPets[index].resistBD.toString());
			labelResistHS.setText(isNull ? "0" : CharInfo.m_arPets[index].resistHS.toString());
			
			btn_change_name.setEnabled(!isNull);
			btn_pet_free.setEnabled(!isNull);
			btn_pet_battle.setEnabled(!isNull);
			btn_pet_battle_setting.setEnabled(!isNull);
			var bInBattle:Boolean = (CharInfo.m_nPetJoinBattleIndex == index)&& CharInfo.m_nBattlePartnerType == PanelMain.PARTNER_TYPE_PET; 
			btn_pet_battle.setText(!bInBattle?"参战":"休战");
			
			var bVisible:Boolean = !isNull && CharInfo.m_arPets[index].m_nPoints > 0;
			
			btnHPAdd.setEnabled(!isNull && CharInfo.m_arPets[index].m_nPointHP < CharInfo.m_arPets[index].m_nLevel * 6);
			btnAPAdd.setEnabled(!isNull && CharInfo.m_arPets[index].m_nPointAP < CharInfo.m_arPets[index].m_nLevel * 6);
			btnDPAdd.setEnabled(!isNull && CharInfo.m_arPets[index].m_nPointDP < CharInfo.m_arPets[index].m_nLevel * 6);
			btnSPAdd.setEnabled(!isNull && CharInfo.m_arPets[index].m_nPointSP < CharInfo.m_arPets[index].m_nLevel * 6);
			
			for each(var skill:PanelSkill in _skills)
			{
				skill.item = null;
			}
			
			var nIndex:uint = 0;
			var array:Array = new Array();
			if(!isNull)
				array = CharInfo.m_arPets[index].m_arSkills;
			for each(var item:Object in array)
			{
				_skills[nIndex].item = item;
				nIndex++;
				if(nIndex >= 6)
					break;
			}

			if(isNull)
			{
				btn_pet_white.setEnabled(false);
				btn_pet_green.setEnabled(false);
				btn_pet_blue.setEnabled(false);
				btn_pet_purple.setEnabled(false);
				btn_pet_golden.setEnabled(false);
				
				
			}
			else
			{
				
				btn_pet_white.setEnabled(true);
				btn_pet_green.setEnabled(true);
				btn_pet_blue.setEnabled(true);
				btn_pet_purple.setEnabled(true);
				btn_pet_golden.setEnabled(true);
				
				btn_pet_white.setSelected(false);
				btn_pet_green.setSelected(false);
				btn_pet_blue.setSelected(false);
				btn_pet_purple.setSelected(false);
				btn_pet_golden.setSelected(false);
				
				var itemPet:Object = CharInfo.m_arPets[index];
				var objPetCSV:Object = Client.getInstance().GetPetCSV(itemPet.csv_id);
				if(objPetCSV != null)
				{
					var growth:int = int(itemPet.growth);
					var tmpMin:int = objPetCSV.growth_min;
					var tmpMax:int = tmpMin + (objPetCSV.growth_max - objPetCSV.growth_min)/5;
					btn_pet_white.setToolTipText("白色资质:"+tmpMin+'-'+tmpMax);
					if(growth >= tmpMin && growth < tmpMax) 
					{
						btn_pet_white.setSelected(true);
						selectedButton = btn_pet_white;
					}
					
					tmpMin = tmpMax;
					tmpMax = tmpMin + (objPetCSV.growth_max - objPetCSV.growth_min)/5;
					btn_pet_green.setToolTipText("绿色资质:"+tmpMin+'-'+tmpMax);
					if(growth >= tmpMin && growth < tmpMax) 
					{
						btn_pet_green.setSelected(true);
						selectedButton = btn_pet_green;
					}
					
					tmpMin = tmpMax;
					tmpMax = tmpMin + (objPetCSV.growth_max - objPetCSV.growth_min)/5;
					btn_pet_blue.setToolTipText("蓝色资质:"+tmpMin+'-'+tmpMax);
					if(growth >= tmpMin && growth < tmpMax) 
					{
						btn_pet_blue.setSelected(true);
						selectedButton = btn_pet_blue;
					}
					
					tmpMin = tmpMax;
					tmpMax = tmpMin + (objPetCSV.growth_max - objPetCSV.growth_min)/5;
					btn_pet_purple.setToolTipText("紫色资质:"+tmpMin+'-'+tmpMax);
					if(growth >= tmpMin && growth < tmpMax) 
					{
						btn_pet_purple.setSelected(true);
						selectedButton = btn_pet_purple;
					}
					
					tmpMin = tmpMax;
					tmpMax = objPetCSV.growth_max;
					btn_pet_golden.setToolTipText("金色资质:"+tmpMin+'-'+tmpMax);
					if(growth >= tmpMin && growth < tmpMax) 
					{
						btn_pet_golden.setSelected(true);
						selectedButton = btn_pet_golden;
					}
				}
			}
		}
		private function onBtnGrowth(e:Event):void
		{
			btn_pet_white.setSelected(false);
			btn_pet_green.setSelected(false);
			btn_pet_blue.setSelected(false);
			btn_pet_purple.setSelected(false);
			btn_pet_golden.setSelected(false);
			if(selectedButton != null)
				selectedButton.setSelected(true);
		}
		private function onJoinBattle(e:Event):void
		{
			if(selectedIndex != -1)
			{
				var bInBattle:Boolean = (CharInfo.m_nPetJoinBattleIndex == selectedIndex)&& CharInfo.m_nBattlePartnerType == PanelMain.PARTNER_TYPE_PET; 
				Client.getInstance().sendPacketLogic(102,[int(!bInBattle?1:0),selectedIndex]);
			}		
		}
		
		private function onBtnBattleSetting(e:Event):void
		{
			FrameBattleSetting.show(_frame,FrameBattleSetting.BATTLE_SETTING_TYPE_PET);
		}
		
		private function onBtnFree(e:Event):void
		{
			var pane:FrameInfo = FrameInfo.showMessageDialog("","是否将宠物 "+labelName.getText() +" 释放?",handleOptionRemovePet,null,true,null,JOptionPane.YES|JOptionPane.NO);
		}
		
		
		private function handleOptionRemovePet(button:uint):void
		{
			if(button == JOptionPane.YES)
			{
				if(selectedIndex != -1)
					Client.getInstance().sendPacketLogic(104,[selectedIndex,CharInfo.m_arPets[selectedIndex].id]);
			}
		}
		
		public static function phPetChangeName_101(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phPets_101", msg);
			var nIndex:uint = 0;
			var nPetIndex:int = msg[nIndex++];
			var m_szCharName:String = msg[nIndex++];
			if(nPetIndex >= CharInfo.m_arPets.length)
			{
				trace("nPetIndex >= CharInfo.m_arPets.length")
				return ;
			}
			CharInfo.m_arPets[nPetIndex].name = m_szCharName;
			CharInfo.m_nPetJoinBattleIndex == -1
			//PanelMainHelp.getInstance().labelPetName.setText(CharInfo.m_nJoinBattleIndex == -1 ? "" : CharInfo.m_arPets[CharInfo.m_nJoinBattleIndex].name);
		}
		
		public static function phPetJoinBattle_102(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phPetJoinBattle_102", msg);
			var nIndex:uint = 0;
			var nPetIndex:int = msg[nIndex++];
			if(nPetIndex >= CharInfo.m_arPets.length)
			{
				trace("nPetIndex >= CharInfo.m_arPets.length")
				return ;
			}
			CharInfo.m_nPetJoinBattleIndex = nPetIndex;
			if(FramePet.isShowing())
			{
				FramePet._frame.onUpdateData();
			}
			//_panelMainHelp.labelPetName.setText(CharInfo.m_arPets[nPetIndex].name);
			PanelMainHelp.getInstance().onPartnerInfoUpdate();
		}
		
		
		
		public static function phPets_100(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phPets_100", msg);
			var nIndex:uint = 0;
			var nCount:uint = msg[nIndex++];
			CharInfo.m_nPetJoinBattleIndex = msg[nIndex++];
			var array:Array = CharInfo.m_arPets;
			array.splice(0,array.length);
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.index = i;
				obj.id = msg[nIndex++];
				obj.csv_id = msg[nIndex++];
				obj.m_nInnerId = msg[nIndex++];
				obj.name = msg[nIndex++];
				obj.m_nLevel = msg[nIndex++];
				obj.growth = msg[nIndex++];
				obj.exp = msg[nIndex++];
				obj.exp_max = msg[nIndex++];
				
				obj.m_szCharName = obj.name;
				obj.m_nLevel = obj.m_nLevel;
				
				obj.hp_max = msg[nIndex++];
				obj.m_nNextPointHP = msg[nIndex++];
				obj.m_nNextPointMoneyHP = msg[nIndex++];
				
				obj.ap = msg[nIndex++];
				obj.m_nNextPointAP = msg[nIndex++];
				obj.m_nNextPointMoneyAP = msg[nIndex++];
				
				obj.dp = msg[nIndex++];
				obj.m_nNextPointDP = msg[nIndex++];
				obj.m_nNextPointMoneyDP = msg[nIndex++];
				
				obj.sp = msg[nIndex++];
				obj.m_nNextPointSP = msg[nIndex++];
				obj.m_nNextPointMoneySP = msg[nIndex++];
				
				obj.resistHL = msg[nIndex++];
				obj.resistBD = msg[nIndex++];
				obj.resistHS = msg[nIndex++];
				
				obj.m_nPointHP = msg[nIndex++];
				obj.m_nPointAP = msg[nIndex++];
				obj.m_nPointDP = msg[nIndex++];
				obj.m_nPointSP = msg[nIndex++];
				//obj.m_nPoints = msg[nIndex++];
				
				obj.m_arSkills = new Array();
				var nSkills:uint = msg[nIndex++];
				for(var j:int = 0; j < nSkills; j++)
				{
					var objSkill:Object = new Object();
					objSkill.csv_id = msg[nIndex++];
					objSkill.m_nLevel = msg[nIndex++];
					obj.m_arSkills[j] = objSkill;
				}
				
				obj.m_nBattleMode = msg[nIndex++];
				obj.m_arAutoBattleSkills = [];
				for(var k:int = 0; k < 6; k++)
					obj.m_arAutoBattleSkills[k] = msg[nIndex++];
				obj.m_arAutoBattleSkillsSoul = [];
				for(k = 0; k < 6; k++)
					obj.m_arAutoBattleSkillsSoul[k] = msg[nIndex++];
			}
			
			if(CharInfo.m_nPetJoinBattleIndex >= array.length || CharInfo.m_nPetJoinBattleIndex < 0)
			{
				trace("CharInfo.m_nJoinBattleIndex >= array.length", msg);
				CharInfo.m_nPetJoinBattleIndex = -1;
			}
			if(FramePet.isShowing())
			{
				FramePet._frame.onUpdateData();
			}
			
			if(_frame == null)
			{
				_frame = new FramePet();
				PanelMainHelp.getInstance().addChild(_frame);
				FramePet._frame.onUpdateData();
				FramePet.hide();
			}

			PanelMainHelp.getInstance().onPartnerInfoUpdate();
			if(FrameStrengthen.isShowing())
				FrameStrengthen._frame.update();
			if(FrameBattleSetting.isShowing())
				FrameBattleSetting._frame.update();
		}
		
		public static var _frame:FramePet = null;
		public static function show():void
		{
			//if(CharInfo.m_arPets == null || CharInfo.m_arPets.length == 0)
			//{
			//	PanelMain.showInfoTimeLimit("没有宠物,任务和各种战斗都会有机会获得宠物!");
			//	return;
			//}
			if(isShowing())
			{
				hide();
				return;
			}
			if(_frame == null)
			{
				_frame = new FramePet();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			_frame.show();
			PanelMainHelp.getInstance().bringToTop(_frame);
			_frame.update();
			
		}
		public static function hide():void
		{
			if(isShowing())_frame.hide();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
	}
}

import com.*;
import com.Engine.*;
import com.Packet.*;
import com.UI.*;

import flash.display.*;
import flash.display.BitmapData;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;
import flash.utils.ByteArray;
import flash.utils.getQualifiedClassName;

import org.aswing.*;
import org.aswing.border.*;
import org.aswing.border.EmptyBorder;
import org.aswing.colorchooser.*;
import org.aswing.dnd.*;
import org.aswing.event.*;
import org.aswing.ext.*;
import org.aswing.geom.*;
import org.aswing.graphics.*;
import org.aswing.tree.AbstractLayoutCache;
//import src.*;

/**
 * MyPanePetItem
 */
class PanePetItem extends JPanel{
	
	//members define
	private var panel_pet_head:JPanel;
	private var label_pet_name:JLabel;
	private var label_pet_level:JLabel;
	private var label_pet_life:JLabel;
	
	/**
	 * MyPanePetItem Constructor
	 */
	public function PanePetItem(){
		//component creation
		setSize(new IntDimension(163, 80));
		setPreferredSize(new IntDimension(163, 80));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panel_pet_head = new JPanel();
		panel_pet_head.setLocation(new IntPoint(5, 5));
		panel_pet_head.setSize(new IntDimension(69, 69));
		panel_pet_head.setPreferredSize(new IntDimension(69, 69));
		
		label_pet_name = new JLabel();
		label_pet_name.setLocation(new IntPoint(75, 7));
		label_pet_name.setSize(new IntDimension(86, 16));
		label_pet_name.setPreferredSize(new IntDimension(86, 16));
		label_pet_name.setText("label");
		
		label_pet_level = new JLabel();
		label_pet_level.setLocation(new IntPoint(75, 32));
		label_pet_level.setSize(new IntDimension(86, 16));
		label_pet_level.setPreferredSize(new IntDimension(86, 16));
		label_pet_level.setText("label");
		
		label_pet_life = new JLabel();
		label_pet_life.setLocation(new IntPoint(75, 56));
		label_pet_life.setSize(new IntDimension(86, 16));
		label_pet_life.setPreferredSize(new IntDimension(86, 16));
		label_pet_life.setText("label");
		
		//component layoution
		append(panel_pet_head);
		append(label_pet_name);
		append(label_pet_level);
		append(label_pet_life);
		
		//----------------------------
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		
		label_pet_name.setFont(font);
		label_pet_name.setForeground(ASColor.WHITE);
		label_pet_name.setTextFilters(new Array(filter));
		label_pet_level.setFont(font);
		label_pet_level.setForeground(ASColor.WHITE);
		label_pet_level.setTextFilters(new Array(filter));
		label_pet_life.setFont(font);
		label_pet_life.setForeground(ASColor.WHITE);
		label_pet_life.setTextFilters(new Array(filter));
		
		var img_char_background:DisplayObject = Client.getUIElement(_selected?"img_pet_item_bg_selected":"img_pet_item_bg") as DisplayObject
		setBackgroundDecorator(new AssetBackground(img_char_background));
		
		addEventListener(MouseEvent.CLICK, onClick);
		addEventListener(MouseEvent.ROLL_OVER, onRollOver);
		addEventListener(MouseEvent.ROLL_OUT, onRollOut);
	}
	private function onClick(event:MouseEvent):void
	{
		if(_item != null)
		{
			FramePet._frame.updatePet(_item.index);
			if(!selected)
				selected = true;
		}
	}
	private var _monuseOn:Boolean = false;
	private function onRollOver(event:MouseEvent):void
	{
		if(!_monuseOn)
		{
			var filter:GlowFilter;
			filter = new GlowFilter(0xffff00, 1, 2, 2, 100);
			this.filters = new Array(filter);
			_monuseOn = true;
		}
	}
	
	private function onRollOut(event:MouseEvent):void
	{
		if(_monuseOn)
		{
			this.filters = null;
			_monuseOn = false;
		}
	}
	//private var _tooltip:ToolTipItemCSV = new ToolTipItemCSV(0);
	private var _item:Object = null;
	public function set item(val:Object):void
	{
		if(_mcPet != null && panel_pet_head.containsChild(_mcPet))
		{
			panel_pet_head.removeChild(_mcPet)
			_mcPet = null;
		}
		_item = val;
		panel_pet_head.setBackgroundDecorator(null);
		label_pet_name.setText("");
		label_pet_level.setText("");
		label_pet_life.setText("");
		selected = _item != null && (FramePet._frame.selectedIndex == _item.index);
		if(_item == null)
		{
			return;
		}
		if(_item.csv_id < 0)
		{
			return;
		}
		
		//panel_pet_head.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_map_"+ _item.csv_id) as DisplayObject));
		label_pet_name.setText(_item.name);
		label_pet_level.setText('Lv.'+_item.m_nLevel);
		label_pet_life.setText('资质:'+_item.growth);
		
		var objPetCSV:Object = Client.getInstance().GetPetCSV(_item.csv_id);
		if(objPetCSV != null)
		{
			LoaderManager.getInstance().load(Engine.assetMapMonsterPath + "npc_"+ objPetCSV.image_id + '.swf',onLoaded);
			

				var growth:int = int(_item.growth);
				var tmpMin:int = objPetCSV.growth_min;
				var tmpMax:int = tmpMin + (objPetCSV.growth_max - objPetCSV.growth_min)/5;

				if(growth >= tmpMin && growth < tmpMax) 
				{
					label_pet_name.setForeground(ASColor.WHITE);
					label_pet_level.setForeground(ASColor.WHITE);
					label_pet_life.setForeground(ASColor.WHITE);
				}
				
				tmpMin = tmpMax;
				tmpMax = tmpMin + (objPetCSV.growth_max - objPetCSV.growth_min)/5;

				if(growth >= tmpMin && growth < tmpMax) 
				{
					label_pet_name.setForeground(ASColor.GREEN);
					label_pet_level.setForeground(ASColor.GREEN);
					label_pet_life.setForeground(ASColor.GREEN);
				}
				
				tmpMin = tmpMax;
				tmpMax = tmpMin + (objPetCSV.growth_max - objPetCSV.growth_min)/5;

				if(growth >= tmpMin && growth < tmpMax) 
				{
					label_pet_name.setForeground(ASColor.HALO_BLUE);
					label_pet_level.setForeground(ASColor.HALO_BLUE);
					label_pet_life.setForeground(ASColor.HALO_BLUE);
				}
				
				tmpMin = tmpMax;
				tmpMax = tmpMin + (objPetCSV.growth_max - objPetCSV.growth_min)/5;

				if(growth >= tmpMin && growth < tmpMax) 
				{
					label_pet_name.setForeground(new ASColor(0xff00ff));
					label_pet_level.setForeground(new ASColor(0xff00ff));
					label_pet_life.setForeground(new ASColor(0xff00ff));
				}
				
				tmpMin = tmpMax;
				tmpMax = objPetCSV.growth_max;

				if(growth >= tmpMin && growth < tmpMax) 
				{
					label_pet_name.setForeground(new ASColor(0xeeee00));
					label_pet_level.setForeground(new ASColor(0xeeee00));
					label_pet_life.setForeground(new ASColor(0xeeee00));
				}
			
		}
		
		pack();
		this.paintImmediately();
		
		
	}
	public function get item():Object
	{
		return _item;
	}
	private var _selected:Boolean = false;
	static private var _selectedPetOld:PanePetItem = null;
	public function set selected(val:Boolean):void
	{
		if(_selected != val)
		{
			setBackgroundDecorator(null);
			_selected = val;
			var img_char_background:DisplayObject = Client.getUIElement(_selected?"img_pet_item_bg_selected":"img_pet_item_bg") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_char_background));
			if(_selected)
			{
				if(_selectedPetOld != null && _selectedPetOld != this)
				{
					_selectedPetOld.selected = false;
				}
				_selectedPetOld = this;
			}
		}
		
	}
	public function get selected():Boolean
	{
		return _selected;
	}
	//private var _loader:LoaderData;
	private var _mcPet:MovieClip = null;
	
	private function onLoaded(e:Event):void
	{
		var l:LoaderInfo=e.target as LoaderInfo;
		l.removeEventListener(Event.COMPLETE,onLoaded);
		//l.removeEventListener(IOErrorEvent.IO_ERROR,onLoadedError);
		var loader:LoaderData = l.loader as LoaderData;
		if(loader != null)
		{
			var _appDomain:ApplicationDomain = loader.contentLoaderInfo.applicationDomain;
			
			//var mcTmp:MovieClip = Engine.getElement(_appDomain,"mc_object") as MovieClip;
			if(_mcPet != null && panel_pet_head.containsChild(_mcPet))
			{
				panel_pet_head.removeChild(_mcPet)
				_mcPet = null;
			}
			_mcPet = Engine.getElement(_appDomain,"mc_object_stand") as MovieClip;//e.target.content as MovieClip;//
			if(_mcPet == null)
				return;
			_mcPet.cacheAsBitmap = true;
			_mcPet.gotoAndStop(1);
			_mcPet.scaleX = panel_pet_head.height/_mcPet.height;
			_mcPet.scaleY = panel_pet_head.height/_mcPet.height;
			_mcPet.x = (panel_pet_head.width - _mcPet.width)/2;//+_mcPet.width/2;
			_mcPet.y = 0;//_mcPet.height;
			panel_pet_head.setBackgroundDecorator(null);
			panel_pet_head.addChildAt(_mcPet,0);
			do
			{
				/*if(CharInfo.m_nJoinBattleIndex == _item.index && !CharInfo.objLover.m_bLoverJoinBattle)
				{
					if(FramePet._mcPetHead != null && PanelMainHelp.getInstance().panel_pet_head.containsChild(FramePet._mcPetHead))
					{
						PanelMainHelp.getInstance().panel_pet_head.removeChild(FramePet._mcPetHead)
						FramePet._mcPetHead = null;
					}
					//if(FrameLover._mcPetHead != null && PanelMainHelp.getInstance().panel_pet_head.containsChild(FrameLover._mcPetHead))
					//{
					//	PanelMainHelp.getInstance().panel_pet_head.removeChild(FrameLover._mcPetHead)
						//PanelPetLover._mcPetHead = null;
					//}
					FramePet._mcPetHead = Engine.getElement(_appDomain,"mc_object_prepare") as MovieClip;
					if(FramePet._mcPetHead == null)
						break;
					FramePet._mcPetHead.gotoAndStop(0);
					FramePet._mcPetHead.scaleX = 1;
					FramePet._mcPetHead.scaleY = 1;
					var imgSelf:JPanel = PanelMainHelp.getInstance().panel_pet_head;
					FramePet._mcPetHead.x = (imgSelf.width - FramePet._mcPetHead.width)/2;//+_mcPetHead.width/2;
					FramePet._mcPetHead.y = 0;//_mcPetHead.height;
					imgSelf.setBackgroundDecorator(null);
					imgSelf.addChildAt(FramePet._mcPetHead,0);
				}*/
			}while(0)
			//if(_loader != null)
			//{
			//	_loader.unloadAndStop();
			//	_loader = null;
			//}
		}
		//else
		//{
		//	loader.unloadAndStop();
		//	loader = null;
		//}
	}
	
	/*private function onLoadedError(e:IOErrorEvent):void
	{
		try
		{
			var l:LoaderInfo=e.target as LoaderInfo;
			var loader:LoaderData = l.loader as LoaderData;
			l.removeEventListener(Event.COMPLETE,onLoaded);
			l.removeEventListener(IOErrorEvent.IO_ERROR,onLoadedError);
			if(_loader != null)
			{
				_loader.unloadAndStop();
				_loader = null;
			}
			else
			{
				loader.unloadAndStop();
				loader = null;
			}
		}
		catch(e:Error)
		{
			trace("onLoadedError")
		}
	}*/
	public function clear():void
	{
		setBackgroundDecorator(null);
		panel_pet_head.setBackgroundDecorator(null);
		item = null;
		//if(_loader != null)
		//{
		//	_loader.unloadAndStop();
		//	_loader = null;
		//}
	}
	//_________getters_________
	
	
}

/*class DraggingImageSkillPet implements DraggingImage
{
	private var initiator:PanelSkillPet;
	
	public function DraggingImageSkillPet(dragInitiator : PanelSkillPet)
	{
		initiator = new PanelSkillPet();
		initiator.height = dragInitiator.height;
		initiator.width = dragInitiator.width;
		initiator.setLocationXY(0,0);
		initiator.setBackgroundDecorator(new AssetBackground(Client.getSkillElement("img_skill_"+dragInitiator.icon_id) as DisplayObject));
	}
	
	public function getDisplay():DisplayObject
	{
		return initiator;
	}
	
	public function switchToAcceptImage() : void 
	{
		
		var filter:GlowFilter;
		filter = new GlowFilter(0x00ff00, 1, 2, 2, 10);
		initiator.filters = new Array(filter);
	}
	

	public function switchToRejectImage() : void 
	{
		var filter:GlowFilter;
		filter = new GlowFilter(0xff0000, 1, 2, 2, 10);
		initiator.filters = new Array(filter);
	}
	
}

class PanelSkillPet extends JPanel
{
	public var icon_id:uint = 0;
	public var index:uint = 0;
	public function PanelSkillPet()
	{
	}
	public function clear():void
	{
		setBackgroundDecorator(null);
	}
}*/